<template>
  <div>
    <!--   searchForm-->
    <el-form
      ref="searchForm"
      class="searchForm"
      :model="searchForm"
      label-width="auto"
      label-position="right"
    >
      <el-row gutter="12">
        <!--        合计24份  -->
        <el-col span="6">
          <el-form-item prop="queryCondition.similarName" label="姓名">
            <el-input v-model.trim="searchForm.queryCondition.similarName">
            </el-input>
          </el-form-item>
        </el-col>
        <el-col span="6">
          <el-form-item prop="queryCondition.code" label="学号">
            <el-input v-model="searchForm.queryCondition.code"> </el-input>
          </el-form-item>
        </el-col>
        <el-col span="6">
          <el-form-item prop="queryCondition.min" label="最小值">
            <el-input v-model="searchForm.queryCondition.min"> </el-input>
          </el-form-item>
        </el-col>
        <el-col span="6">
          <el-form-item prop="queryCondition.max" label="最大值">
            <el-input v-model="searchForm.queryCondition.max"> </el-input>
          </el-form-item>
        </el-col>
      </el-row>

      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-edit"
          @click="queryByCondition(1)"
          >查询</el-button
        >
        <el-button
          type="warning"
          icon="el-icon-remove"
          @click="() => $refs.searchForm.resetFields()"
          >重置</el-button
        >
      </el-form-item>
    </el-form>
    <el-table :data="results" class="resultsTable"  stripe>
      <el-table-column prop="scoreId" label="ID/Code"></el-table-column>
      <el-table-column prop="name" label="名字"></el-table-column>
      <el-table-column prop="onlineScore" label="在线成绩！"></el-table-column>
      <el-table-column prop="classScore" label="课堂成绩？"></el-table-column>
      <el-table-column label="code" :formatter="codeFormat"> </el-table-column>

      <el-table-column width="180px" fixed="left">
        <template slot-scope="props">
          <el-button
            class="el-button--mini"
            type="warning"
            icon="el-icon-edit"
            @click="openById(props.row.scoreId)"
            >编辑</el-button
          >
          <el-button
            class="el-button--mini"
            type="danger"
            icon="el-icon-delete"
            @click="delete props.row.scoreId"
            >删除</el-button
          >
        </template>
      </el-table-column>
    </el-table>
    <!--      table-->
    <el-pagination
      :total="total"
      :page-size="searchForm.pageSize"
      :current-page="searchForm.pageNum"
      @current-change="queryByCondition"
      layout="total, prev, pager, next, jumper"
    ></el-pagination>
    <!--      pagination-->
  </div>
</template>

<script>
// import New from './components/New.vue';
export default {
  name: "Sixth",
  components: {
    // New,Old,
  },
  props: {
    sampleP: {
      type: Number,
      default: 0,
    },
  },
  data() {
    return {
      sampleD: "value",
      searchForm: {
        pageNum: 1,
        pageSize: 8,
        queryCondition: {
          code: null,
          maxOnline: 0,
          minOnline: 0,
          similarName: "",
        },
      },

      total: 0,
      results: [
        {
          scoreId: 76,
          code: "8110756",
          name: "王芳",
          onlineScore: 80,
          classScore: 86,
        },
        {
          scoreId: 47,
          code: "8110753",
          name: "张凯",
          onlineScore: 98,
          classScore: 0,
        },
      ],
    };
  },
  computed: {
    // sampleC() {
    //     return this.sampleD+'--';
    // }
  },
  created() {},
  mounted() {
    this.queryByCondition(1);
  },
  methods: {
    sampleM() {},
    queryByCondition(pageNum) {
      if (pageNum) this.searchForm.pageNum = pageNum;
      this.$http({
        method: "post",
        url: "/studentScore/query",
        data: this.searchForm,
      }).then(
        (res) => {
          this.total = res.data.total;
          this.results = res.data.results;
        },
        (error) => {
          this.$message.warning("query mistake：" + error.response.status);
        }
      );
    },
    codeFormat(row) {
      return "__" + row.code;
    },
  },
  watch: {
    // sampleC(newValue, oldValue) {
    //
    // }
  },
};
</script>

<!--<style scoped>-->
<style lang="scss" scoped>
.el-form {
  .el-input {
    width: 120px;
  }
}
</style>
